package com.cike.sparkstudy.sql.scala

import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}

/**
  * 编程方式家在parquet格式数据
  */
object ParquetLoadData extends App {

  val conf = new SparkConf()
    .setMaster("local")
    .setAppName("ParquetLoadData")
  val sc = new SparkContext(conf)
  val sqlContext = new SQLContext(sc)

  val userDF = sqlContext.read.parquet("/developerCodes/test/users.parquet")
  userDF.registerTempTable("users")

  val userNameDF = sqlContext.sql("select name from users")
  userNameDF.rdd.map{row => "Name :" + row(0)}.collect()
    .foreach{userName => println(userName)}


}
